package com.fanrenqiji.modules.sys.dao;

import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.modules.sys.entity.Config;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author lijian E-mail:ljz0721cx@163.com
 * @version 创建时间：2015年2月28日 下午2:45:21
 * @description
 */
public interface ConfigDao extends ConfigDaoCustom, CrudRepository<Config, Long> {

	@Query("from Config where delFlag='" + Config.DEL_FLAG_NORMAL + "' and item = ?1")
	List<Config> findConfigByItem(String item);
	
	@Modifying
	@Query("update Config set delFlag='" + Config.DEL_FLAG_DELETE + "' where id = ?1 ")
	void deleteById(Long id);
	
	@Modifying
	@Query("update Config set isBound= ?1 where id = ?2 ")
	void updateIsBoundById(Boolean b, Long id);
}


interface ConfigDaoCustom extends BaseDao<Config> {
}

@Repository
class ConfigDaoImpl extends BaseDaoImpl<Config> implements ConfigDaoCustom {

}